Patmos “Protected address translation mode operating system” is an application that brings the advantages of protected mode programs to your Quadra class macintosh. By the simple expedient of taking over the memory management unit of the 68040 in a very simple kernel (<100K in size), we immediately gain compatibility with the BSD unix program environment. The advantages of this are as follows:
(a) You can run certain programs (such as /bin/sh) designed for MacBSD
(b) You can compile almost all GNU software including C and C++ without modifying the source code in any way
(c) All programs run with a flat 32-meg address space, with no worries about 32K segments or the other mac paraphernalia
(d) The majority of program bugs can be caught cleanly without crashing your mac
(e) All your files are shared between Patmos and MacOS so you can edit using your favourite mac editor, then immediately compile in Patmos without having to reboot or copy files around.
The downside is that not all macs use the memory management unit in the same way, or even have the same kind of MMU, so Patmos may not run on your particular mac model. However, since the kernel source code is very small, the task of adapting it to a new environment is very simple, and once achieved, all application programs running in user mode are enabled to run without even recompiling.
Currently supported kernel functions:
Protected mode addressing
32Meg virtual address space
Berkley a.out executable model (argc, argv, envp) etc.
linear program growth (sbrk,mmap etc.)
dynamic process sizing (no need to calculate size requirements in advance)
If you have the latest version of Patmos it will be organised
into 3 self-extracting modules:
/bin.sea
/usr.sea
/src/Patmos.sea
You can obtain this software by anonymous ftp
from nic.switch.ch in the /software/mac/src/Patmos subdirectory
The absolute minimum you need to do anything is the kernel (the Patmos application) and shell (sh). This will allow you to determine whether Patmos can run on your machine. These files are present in the /bin.sea archive, together with most of
the small programs that you can typically run from a UNIX shell
The /usr.sea archive contains everything needed to compile and run a C program
that uses the stdio library. This includes everything mentioned above including
the compiler itself.
The /src/Patmos.sea archive contains what is needed to re-compile or debug
the Patmos kernel. You will also need THINK C 5.04 or later. For your convenience
the library include files are already converted to THINK format to drop right into
your THINK-C folder. You will need to turn off the normal THINK-C standard libraries
and headers because they are incompatible with BSD UNIX on the whole. This can be
done by putting brackets () around the (C libraries) folder in the THINK folder. This procedure is documented in the THINK manuals.
Create a top level folder, called 'root' for example on your hard disk. Extract the
archive(s) into this folder. Copy sh from the bin folder into the root.
It is desirable but not essential to create /tmp and /var/tmp directories to hold temporary files for the compiler.
You should end up with a structure much like this.
HD80:
root:
Patmos
sh
COPYING
bin
usr
src
tmp
The root directory '/' for Patmos will be the folder containing the first file
opened. After startup. This is conveniently done by dragging and dropping the
'sh' in the 'root' folder onto the 'Patmos' Application.
You can use other directory structures if you wish but this is untested.
If you have an older version of Patmos the structure and archive names
may be slightly different but things should still work the same.
You do not need to set the memory size requirements of Patmos programs
but you do need to set the total partition. This should be as large as possible
leaving room for the system, your favourite editor, and the finder.
3000K should be adequate to compile a noddy program
6000K would be typical if you are using make and/or build scripts
9000K should be sufficient if you want to rebuild the compiler or your latest
multi-megabyte epic project.
Getting started.
Turn off virtual memory, RAM doubler, Appletalk before attempting to run
Patmos. Other obscure system extensions could interfere as well.
Make sure you boot in 32-bit mode. I hope to have a version
compatible with Appletalk soon, but Patmos takes over the MMU so it is
fundamentally incompatible with Apple virtual memory and RAM doubler.
You can still use Autodoubler etc. if you have it to reduce the size of your
executables. Since all filing system calls are via the toolbox, the operation
of this type of program is transparent to Patmos.
At startup, the Patmos application will perform some basic checks to see if the machine seems suitable before continuing. It will also consult a database of tested machines to warn you if your machine has ever been tested before. You can add to this database in the application by editing STR# resource 128. Just add the name of your machine as it appears in the “About this macintosh” box. Once you are happy Patmos is working, you can startup by simply dropping the sh program on the Patmos application. Note that the location of the sh program becomes the root of the filing system for that session, so you will need two copies of sh, one in your root folder, and one in your /bin folder.
To compile and run a program you will need
/usr/lib/crt0.o
/usr/lib/libgcc.a
/usr/lib/libc.a
/usr/bin/{gcc,cpp,cc1,as,ld}
You can prepare your source code with an editor such as the freeware BBEdit-2.2.2, be sure to choose the ‘UNIX line endings’ option when you save the source file. A typical compilation command would be
gcc plugh.c where plugh.c is your program
this will generate an executable in the current directory, called a.out by default
Run this program by typing
a.out
The program’s output will appear in the console window, or else a diagnostic message giving an error, and the CPU registers at the time of the error, and if possible, the offending instruction.
If you are unfamiliar with the usage of the GNU software, all the source code and manual pages and documentation should be available from the same site you got Patmos from, as well as many other places. The most convenient way to get new source code to compile and run is on the many CDroms that are available.
The majority of recent mac
models use a cut down 68LC040 with no maths co-processor so the kernel
and most programs assume the co-processor is unused. You could alter
the kernel to save the FPU context if you have a full 68040 and this would
then work in conjunction with gcc -m68040. You might need to edit the gcc specs